package cc.mrbird.febs.power.controller;


import cc.mrbird.febs.common.utils.R;
import cc.mrbird.febs.power.entity.AccountLoginLogInfo;
import cc.mrbird.febs.power.service.IAccountLoginLogInfoService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * @author MrBird
 */
@RestController
@RequestMapping("/power/account-login-log-info")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AccountLoginLogInfoController {

    private final IAccountLoginLogInfoService iAccountLoginLogInfoService;

    /**
     * 分页查询登录信息
     * @param page
     * @param accountLoginLogInfo
     * @return
     */
    @GetMapping("/page")
    public R getAccountLoginLogInfoByPage(Page page,AccountLoginLogInfo accountLoginLogInfo) {
        return R.ok(iAccountLoginLogInfoService.page(page, Wrappers.<AccountLoginLogInfo>lambdaQuery().eq(accountLoginLogInfo.getAccountCode()!=null,AccountLoginLogInfo::getAccountCode,accountLoginLogInfo.getAccountCode())
                .eq(accountLoginLogInfo.getLoginStatus()!=null,AccountLoginLogInfo::getLoginStatus,accountLoginLogInfo.getLoginStatus())));
    }

    /**
     * 新增登录日志
     * @param accountLoginLogInfo
     * @return
     */
    @PostMapping("/AccountLoginLogAdd")
    public R AccountLoginLogAdd(AccountLoginLogInfo accountLoginLogInfo) {
        return R.ok(iAccountLoginLogInfoService.save(accountLoginLogInfo));
    }


}
